const click = (e) => {
    e.stopPropagation();
    console.log(e);
    console.log(e.target);

    let url = document.querySelector('#currentUrl').value || getQueryStringByName("url");
    let eventType = e.type;
    let locator = getXpath(e.target);
    window.location.href = `http://localhost:8080/render?url=${encodeURI(url)}&eventType=${eventType}&locator=${encodeURI(locator)}`;
    e.returnValue = false
};

//根据QueryString参数名称获取值
function getQueryStringByName(name){
    let result = location.search.match(new RegExp("[\?\&]" + name+ "=([^\&]+)","i"));
    if(result == null || result.length < 1){
        return "";
    }
    return result[1];
}

function getXpath(ele) {
    //todo 获取xpath
    return ""
}

document.querySelectorAll('*').forEach(n => {
    n.addEventListener('click', click)
});

console.log(document.querySelector('#currentUrl'));